//
//  ZFZMAuthorizeViewController.m
//  HappilyLoan
//
//  Created by zainishenbian on 2017/4/12.
//  Copyright © 2017年 zongqingxiangqian. All rights reserved.
//

#import "ZFZMAuthorizeViewController.h"
#import "ZFHeader.h"

@interface ZFZMAuthorizeViewController ()<WKUIDelegate,WKNavigationDelegate>{
    WKWebView *webV;
}
@property (nonatomic,strong) AnimatingView *anima;
@end

@implementation ZFZMAuthorizeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"芝麻授权";
    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"叉"] style:UIBarButtonItemStylePlain target:self action:@selector(closeVC)];
    self.navigationItem.rightBarButtonItem = rightButton;
    
    
    [self performSelector:@selector(loadDoneFeed) withObject:nil afterDelay:0.5];
    self.view.backgroundColor = BGCOLOR;
    
    self.anima = [[AnimatingView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
}
- (void)loadDoneFeed{
    [_anima stopTheAnimation];
    webV = [[WKWebView alloc] init];
    webV.frame = CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT);
    [self.view addSubview:webV];
    
    [webV loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_ZMUrl]]];
}
#pragma mark ———— button的点击事件
- (void)webViewDidStartLoad:(UIWebView *)webView {
    //    [_anima startTheSmallAnimation];//开始动画
    //    NSLog(@"开始加载");
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    //    NSLog(@"加载完成");
    [_anima stopTheAnimation];
}
- (void)closeVC
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"myAuthorizeView"];
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    [_anima startTheAnimation];//开始动画
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"myAuthorizeView"];
    [_anima stopTheAnimation];
}
#pragma mark ———— 返回
- (BOOL)navigationShouldPopOnBackButton
{
    if (webV.canGoBack) {
        
        [webV goBack];
        return NO;
    }
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
